var mongoose = require('../common/db');

var mail = new mongoose.Schema({
    fromUser: String,
    toUser: String,
    title: String,
    context: String
})
mail.statics.findByToUserId = async function (user_id) {
    return await this.find({ toUser: user_id }).exec();
};
mail.statics.findByFromUserId = async function (user_id) {
    return await this.find({ fromUser: user_id }).exec;
};

var mailModel = mongoose.model('mail', mail);

module.exports = mailModel